package com.sc.nft.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sc.nft.entity.PayOrder;
import com.sc.nft.entity.SecondCollectionConfig;
import com.sc.nft.entity.SecondOrder;
import com.sc.nft.entity.UserInfo;
import com.sc.nft.entity.dto.*;
import com.sc.nft.entity.vo.*;
import com.sc.nft.enums.MarketTypeEnum;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 新的2级商城通用模块
 * 所有的公共抽离的模块全部在这里.
 */
public interface NewSecondCollectionCommonService {

    /**
     * 预查询超时订单
     *
     * @return
     */
    List<SecondOrder> getPreTimeOutOrderIds(Date time);

    /**
     * 获取选择商品的总价
     *
     * @param goodsTotalMoneyDTO
     * @return
     */
    BigDecimal selectGoodsTotalPrice(GoodsTotalMoneyDTO goodsTotalMoneyDTO);

    /**
     * 用户是否有充足的购买数量
     * 请注意:这里并非是商品不足,而是每一个用户购买的数量上限是有要求的
     *
     * @return
     */
    Boolean userBuySumInsufficient(UserInfo userInfo, Long collectionId, Integer sum);


    /**
     * 库存退回
     *
     * @param collectionId
     * @param secondCollectionIds
     */
    void backSalesCollection(Long collectionId, List<String> secondCollectionIds);
    /**
     * 二级支付成功
     *
     * @param secondOrders
     */
    void paySuccess(List<SecondOrder> secondOrders);

    /**
     * 通过缓存获取孵化区藏品
     *
     * @param userInfo
     * @param collectionId
     * @param count
     * @return
     */
    List<Long> getBrandSecondCollectionIdsWithCache(SecondCollectionConfig collectionConfig, UserInfo userInfo, Long collectionId, Integer count);
    List<Long> getBrandSecondCollectionIdsWithDB(SecondCollectionConfig collectionConfig, UserInfo userInfo, Long collectionId, Integer count);


    /**
     * 锁单
     */
    LockOrderVO lockOrder(UserInfo userInfo, NewSecondCollectionLockOrder newSecondCollectionLockOrder);

    /**
     * 孵化市场锁单
     *
     * @param userInfo
     * @param collectionId
     * @param secondCollectionIds
     * @return
     */
    LockOrderVO lockBrandOrder(UserInfo userInfo, Long collectionId, List<Long> secondCollectionIds);


    /**
     * 获取藏品购买确认页面数据
     *
     * @return
     */
    CollectionBuyConfirmVO collectionBuyConfirm(UserInfo userInfo, CollectionBuyConfirmDTO collectionBuyConfirmDTO);


    /**
     * 新二级商品批量购买的时候的购买列表
     *
     * @param newSecondCollectionGoodsBuyListDTO
     * @return
     */
    List<NewSecondCollectionGoodsBuyListVO> newSecondCollectionGoodsBuyList(UserInfo userInfo, NewSecondCollectionGoodsBuyListDTO newSecondCollectionGoodsBuyListDTO);
    void cacheMaxId();
    /**
     * 获取用户的订单
     *
     * @return
     */
    Page<NewSecondCollectionGoodsBuyOrderListVO> selectNewSecondCollectionGoodsSaleOrderList(NewSecondCollectionGoodsBuyOrderListDTO newSecondCollectionGoodsBuyOrderListDTO);

    /**
     * 获取用户的买入订单
     *
     * @param newSecondCollectionGoodsBuyOrderListDTO
     * @return
     */
    Page<NewSecondCollectionGoodsBuyOrderListVO> selectNewSecondCollectionGoodsBuyOrderList(NewSecondCollectionGoodsBuyOrderListDTO newSecondCollectionGoodsBuyOrderListDTO);

    /**
     * 新二级合并支付待付款订单数据
     *
     * @return
     */
    NewSecondCollectionNotPayVO newSecondCollectionNotPay();

    /**
     * 根据订单号获取这条订单的数据
     *
     * @param orderId
     * @return
     */
    NewSecondCollectionOrderDetailsVO nweSecondCollectionOrderDetails(Long orderId);

    /**
     * 根据订单号获取这条订单卖出的数据
     *
     * @param orderId
     * @return
     */
    NewSecondCollectionOrderDetailsVO nweSecondCollectionOrderSaleDetails(Long orderId);

    /**
     * 获取用户藏品状态
     *
     * @param getUserItemStatusDTO
     * @return
     */
    GetUserItemStatusVO getUserItemStatus(GetUserItemStatusDTO getUserItemStatusDTO);

    /**
     * 用户商品寄售的时候详情信息
     *
     * @param getUserConsignmentDTO
     * @return
     */
    GetUserConsignmentVO getUserConsignment(GetUserConsignmentDTO getUserConsignmentDTO);

    /**
     * 获取用户寄售藏品价格
     *
     * @param userConsignmentCollectionPriceDTO
     * @return
     */
    UserConsignmentCollectionPriceVO getUserConsignmentCollectionPrice(UserConsignmentCollectionPriceDTO userConsignmentCollectionPriceDTO);

    /**
     * 取消寄售
     *
     * @param cancellationConsignmentDTO
     * @return
     */
    Boolean cancellationConsignment(CancellationConsignmentDTO cancellationConsignmentDTO);

    /**
     * 自由市场上架
     *
     * @param userCollectionId
     * @param buyPrice
     * @param dealPwd
     * @return
     */
    Boolean freeMarketHitShelf(Long userCollectionId, BigDecimal buyPrice, String dealPwd);

    /**
     * 藏品购买限制
     *
     * @return
     */
    Integer commodityPurchaseRestriction(UserInfo userInfo, SecondCollectionConfig secondCollectionConfig);

    /**
     * 获取藏品的详情信息
     *
     * @param collection
     * @return
     */
    GetUserConsignmentVO getCollectionConsignment(Long collection);

    /**
     * 获取用户待付款订单
     *
     * @return
     */
    Boolean getUserOrderExist(Long userId);

//    /**
//     * 获取当天用户黑名单
//     *
//     * @return
//     */
//    List<Long> userBlackList();

    /**
     * 取消订单
     *
     * @param id
     * @param user
     */
    void cancelOrderById(Long id, UserInfo user);
    void cancelOrderById(Long id);

    /**
     * 分页查询我的寄售列表
     *
     * @param user
     * @param pageNo
     * @param pageSize
     * @return
     */
    Page<MyConsignmentListVO> myConsignmentList(UserInfo user, Integer pageNo, Integer pageSize);

    /**
     * 批量取消寄售
     *
     * @param saveBatchCancellationConsignmentDTO
     * @return
     */
    Boolean saveBatchCancellationConsignment(SaveBatchCancellationConsignmentDTO saveBatchCancellationConsignmentDTO);

    /**
     * 分页查询我的挂单
     *
     * @param user
     * @param pageNo
     * @param pageSize
     * @return
     */
    Page<MySalestListVO> mySalestList(UserInfo user, Integer pageNo, Integer pageSize);


    /**
     * 后台市值账号专用
     * @param user
     * @param collectionId
     * @return
     */
    List<MySalestListVO> maintainSalestList(UserInfo user, Long collectionId,BigDecimal lowPrice,BigDecimal highPrice);

    /**
     * 自由出售藏品价格数据
     *
     * @param collectionId
     * @return
     */
    SellCollectionPriceDataVO sellCollectionPriceData(Long collectionId);


    /**
     * 未支付订单价格
     *
     * @param orderNotPayPriceDTO
     * @return
     */
    BigDecimal orderNotPayPrice(OrderNotPayPriceDTO orderNotPayPriceDTO);

    /**
     * DAO自由市场上架
     *
     * @param userCollectionId
     * @param buyPrice
     * @param dealPwd
     * @return
     */
    Boolean daoFreeMarketHitShelf(Long userCollectionId, BigDecimal buyPrice, String dealPwd, Long daoId);
    Map startTime(MarketTypeEnum marketType);

    /**
     * v5.4新版本锁单
     *
     * @param request
     * @return
     */
    LockOrderVO lockBrandOrder(UserInfo userInfo,SecondBrandCollectionLockOrderDTO request);

    /**
     * 获取过期的订单
     * @param user
     * @param page
     * @return
     */
    Page<NewSecondCollectionGoodsBuyOrderListVO> overdueOrderList(UserInfo user, Page page);

    /**
     * 获取过期订单详情
     * @param orderId
     * @return
     */
    SecondOverdueOrderDetailsVO overdueOrderDetails(Long orderId,Long userId);

    String getCacheMinPrice(Long collectionId);
    String getCacheMinPriceForConsensus(Long collectionId);
    String getCacheMinPriceNotInConsensus(Long collectionId);
}
